import * as api from '../api'
export default (state,action)=>{
    state=state || {users:[]}
    switch(action.type){
        case 'USERS':
            return {...state,users:action.users};
        default:
            return state
    }
}
// 1先获取到所有用户表
export const getUsers =(value)=>(dispatch)=>{
    fetch(api.USERS,{
        method:"post",
        headers:{"Content-Type":"application/json"},
        body:JSON.stringify({use:value})
    }).then(req=>req.json()).then(requlst=>{
        // console.log(requlst)
        dispatch({type:'USERS',users:requlst})
        })    
}